Data Structures and Algorithms in Python by Publishing DS

Data Structures and Algorithms in Python by Publishing DS

Author:Publishing, DS [Publishing, DS]
Language: eng
Format: epub
Published: 2019-09-04T16:00:00+00:00


if dataval not in self . stack:

self . stack . append ( dataval )

return True

else :

return False

# Use list pop method to remove element

def remove ( self ):

if len( self . stack) <= 0 :

return ( "No element in the Stack" )

else :

return self . stack . pop ()

AStack = Stack ()

AStack . add ( "Mon" )

AStack . add ( "Tue" )

AStack . add ( "Wed" )

AStack . add ( "Thu" )

print ( AStack . remove ())

print ( AStack . remove ())

When the above code is executed, it produces the following result:

Thu



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.